package ynu.ehall.dao;

import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import ynu.ehall.po.User;

import java.util.List;


@Repository
public interface IUserDao extends CrudRepository<User, String> {
    //根据用户名（主键）和密码查找用户
    User findUserByUserIdAndPassword(Long userId,String password);
    //查找女性用户
    List<User> findUsersBySexFalse();
    //根据用户名修改密码
    @Transactional
    @Modifying
    @Query("update User u set u.password=?1 where u.userId=?2")
    void updatePasswordByUserId(String password,Long userId);
    //根据用户名删除人员信息
    @Transactional
    @Modifying
    void deleteUserByUserId(Long userId);
}
